package com.ruoyi.websocket.controller;

import com.ruoyi.cfuser.api.rescue.domain.RescueTask;
import com.ruoyi.websocket.service.SendMessageService;
import com.ruoyi.websocket.service.SendMessageToUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;


@RestController
@RequestMapping("/websocket")
public class WebSocketController {

    @Resource
    private SendMessageService sendMessageService;
    @Resource
    private SendMessageToUserService sendMessageToUserService;

    @PostMapping
    public void sendMessage(@RequestBody RescueTask rescueTask) {
        sendMessageService.sendMessage(rescueTask);
    }

    @PostMapping("/toUser")
    public void sendMessage(@RequestBody Map<String,Object> map) {
        sendMessageToUserService.sendMessage(map);
    }
}
